package com.umakr.ax.app.web;

import com.umakr.ax.common.service.SeekHelpInfoService;
import com.umakr.ax.core.base.AbstractController;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 求助信息  前端控制器
 * </p>
 *
 * @author Umakr-Code-Generator
 * @since 2017-12-30
 */
@Controller
@RequestMapping("/api/seekHelpInfo")
public class SeekHelpInfoAppController extends AbstractController {
	@Autowired
	SeekHelpInfoService seekHelpInfoService;


	@ApiOperation(value = "发布求助信息")
	@PostMapping(value = "/save")
	public Object save(ModelMap modelMap, @RequestParam(name = "userId") Long userId,
					   @RequestParam(name = "rsId") Long rsId,
					   @RequestParam(name = "seekerName") String seekerName,
					   @RequestParam(name = "seekTitle") String seekTitle,
					   @RequestParam(name = "seekDes") String seekDes,
					   @RequestParam(name = "seekVoice") String seekVoice,
					   @RequestParam(name = "addrCoordinate") String addrCoordinate,
					   @RequestParam(name = "addrStr") String addrStr,
					   @RequestParam(name = "contacts") String contacts,
					   @RequestParam(name = "contactsTell") String contactsTell,
					   @RequestParam(name = "seekType") Integer seekType,
					   @RequestParam(name = "photoInfo") String photoInfo,
					   @RequestParam(name = "radioLen") Integer radioLen,
					   @RequestParam(name = "drivingDirection") String drivingDirection) {

		return setSuccessModelMap(modelMap,seekHelpInfoService.save(userId,rsId,seekerName,seekTitle,seekDes,seekVoice,addrCoordinate,addrStr,contacts,contactsTell,seekType,photoInfo,radioLen,drivingDirection));
	}


	/**
	 * @author 唐腾飞
	 * @param modelMap
	 * @param id
	 * @return
	 */
	@ApiOperation(value = "求助信息详情")
	@GetMapping(value = "/detail")
	public Object detail(ModelMap modelMap,
						 @RequestParam(name="id") Long id) {
		return setSuccessModelMap(modelMap, seekHelpInfoService.detail(id));
	}


	@ApiOperation(value = "读取一键求助/我的求助")
	@GetMapping("/load")
	@ResponseBody
	public Object load(ModelMap modelMap, @RequestParam(name = "type") Integer type, Long userId) {
		return setSuccessModelMap(modelMap,seekHelpInfoService.load(type,userId));
	}
	@ApiOperation(value = "求助信息标识已解决")
	@GetMapping("/updateSeekHelpInfoDealStatus")
	@ResponseBody
	public Object updateSeekHelpInfoDealStatus(ModelMap modelMap,@RequestParam(name = "helpId") Long helpId, @RequestParam(name = "dealStatus") Integer dealStatus) {
		return setSuccessModelMap(modelMap,seekHelpInfoService.updateSeekHelpInfoDealStatus(helpId,dealStatus));
	}

	@ApiOperation(value = "电台软删除求助信息")
	@GetMapping("/delSeekHelpInfo")
	@ResponseBody
	public Object delSeekHelpInfo(ModelMap modelMap,@RequestParam(name = "helpId") Long helpId, @RequestParam(name = "delStatus") Integer delStatus) {
		return setSuccessModelMap(modelMap,seekHelpInfoService.delSeekHelpInfo(helpId,delStatus));
	}

}